<!-- 预警跟踪-详情-高发 -->
<script>
import { warningOfEventList, getStatus } from '@/api/handle'
import QueryTable from '@/mixins/QueryTable'
import { mapGetters } from 'vuex'

export default {
  name: 'indexTable',
  extends: QueryTable,
  props: {
    active: {
      type: String,
      default: ''
    },
    data: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    const areaCode = this.$store.state.user.user.districtNo
    return {
      inputList: {
        data: [
          {
            type: 'input',
            label: '事件类型',
            prop: 'itemName',
            disabled: true
          },
          {
            type: 'input',
            label: '事件编号',
            prop: 'eventCode'
          },
          {
            type: 'input',
            label: '事件标题',
            prop: 'eventTitle'
          },
          {
            type: 'select',
            label: '事件状态',
            prop: 'eventStatus',
            list: []
          },
          {
            type: 'date',
            format: 'yyyy-MM-dd',
            dateType: 'daterange',
            label: '上报时间',
            prop: 'reportTime',
            start: '开始日期',
            end: '结束日期',
            valueFormat: 'yyyy-MM-dd'
          }
        ]
      },
      tableApi: warningOfEventList, // 表格数据API
      tableConfig: {
        columns: [
          {
            label: '事件编号',
            prop: 'eventCode',
            showTooltip: true
          },
          {
            label: '事件来源',
            prop: 'fromName',
            showTooltip: true
          },
          {
            label: '事件标题',
            prop: 'eventTitle',
            showTooltip: true
          },
          {
            label: '事件描述',
            prop: 'eventContent',
            showTooltip: true
          },
          {
            label: '上报时间',
            prop: 'reportTime',
            showTooltip: true
          },
          {
            label: '上报部门',
            prop: 'reportUserDeptName',
            showTooltip: true
          },
          {
            label: '状态',
            prop: 'statusName',
            showTooltip: true
          }
        ],
        btns: [
          {
            text: '详情',
            methods: (row) => this.handleView(row, '详情')
          }
        ]
      },
      customQueryParam: {}
    }
  },
  computed: {
    ...mapGetters(['user'])
  },
  created() {
    this.getDict()
  },

  mounted() {},
  watch: {
    active(val) {
      this.inputList.model.modelType = val
    },
    data(val) {
      this.inputList.model.itemName = val.problemsType
      this.handleSearch()
    }
  },

  methods: {
    getDict() {
      this.getStatus()
    },
    getDefaultModel() {
      return {
        itemName: '',
        eventCode: '',
        eventTitle: '',
        eventStatus: '',
        reportTime: ''
      }
    },
    handleView(row) {
      this.$router.push({
        path: '/warning/track/detail',
        query: {
          modelType: this.active,
          warningCode: row.warningCode
        }
      })
    },
    // 状态
    getStatus() {
      getStatus({}).then((res) => {
        if (!res.success) return
        let list = []
        res.data.map((i) => {
          list.push({ label: i.statusName, value: i.status })
        })
        this.inputList.data[3].list = list
      })
    }
  }
}
</script>
